OPTIMIZE_LEVEL = -O2
WARNING_LEVEL = -Wall
CPP_STANDARD = -std=c++17

CPP_COMPILER = g++ $(CPP_STANDARD) $(OPTIMIZE_LEVEL) $(WARNING_LEVEL)

TARGET = main
CPP_OBJECTS = $(TARGET).o
CPP_DEPENDENCIES = $(patsubst %.o,%.d,$(CPP_OBJECTS))

$(TARGET) : $(CPP_OBJECTS)
	$(CPP_COMPILER) -o $@ $^

$(CPP_OBJECTS) : %.o : %.cpp
	$(CPP_COMPILER) -o $@ -c $<

$(CPP_DEPENDENCIES) : %.d : %.cpp
	$(CPP_COMPILER) -o $@ -MM $<

include $(CPP_DEPENDENCIES)

.PHONY: clean
clean:
	rm $(CPP_OBJECTS) $(CPP_DEPENDENCIES) $(TARGET)
